<script setup lang="ts">
const emits = defineEmits<{
  close: [];
}>();

const { bonuses, bonusesAvailableAt } = queries.useBonusesQuery();
const { levelInfo } = queries.useLevelQuery();
</script>

<template>
  <div class="text-sm text-sys-text-body">
    <div class="mb-4 text-sys-text-head">
      {{ $t('vwIm7RlsltxuHa5JwVxcO') }}
    </div>
    <div>
      {{ $t('n4fMsBvEYpjkMrGXk7im') }}
    </div>
    <div class="mt-2 rounded-2 bg-sys-layer-a px-3 py-2 text-sm">
      <div class="col-span-full mb-1 text-sys-text-head">
        {{ $t('xxn29eOmm4RnCEsDl6AbX') }}
      </div>
      <p class="gray-text mt-1!">
        {{ $t('cuE1tB9iZLhBgtNUg7iHw') }}
      </p>
    </div>
    <div class="line" />

    <div class="divider-h-gradual my-4" />

    <div>
      {{ $t('0mkyelkkltJ72TYwjuR8') }}:
    </div>
    <div class="mt-1 text-sys-text-head">
      {{ $t('c3SodgTiP4lVAb4CmItFv') }}
    </div>

    <div class="divider-h-gradual my-4" />

    <div>
      {{ $t('ajPnzY9unHvL7CMcTXxRo') }}:
    </div>
    <div class="mt-1 text-sys-text-head">
      <span v-if="bonuses?.cashback?.available">{{ $t('a3gI64UuyUDDqUcSm7J') }}</span>
      <AStatisticCountdown
        v-else-if="bonusesAvailableAt.cashback"
        class="ant-cover__StatisticCountdown-inline-inherit"
        :value="bonusesAvailableAt.cashback"
      />
      <span v-else>{{ $t('3rhpsyQm7rJVuUUarTtsg') }}</span>
    </div>

    <div class="divider-h-gradual my-4" />

    <div>
      {{ $t('c7Dg0fUsfJgSmwukRBr0f') }}:
    </div>
    <div class="mt-2 border border-yellow-5 rounded-2 border-solid p-2">
      <div class="flex items-center text-base text-yellow-5">
        <i class="i-local:bonuses--start mr-1 text-1.5em -mb-1" />
        <span>{{ $t('n7RpcyLc9SkiPxDj9i0') }}:</span>
      </div>
      <div>
        {{ $t('hvZiSdCXbHLo5PvFai55E') }}
      </div>
    </div>

    <div class="divider-h-gradual my-4" />

    <div>
      {{ $t('sAaARhdrKIaH8ud3iSd_8') }}:
    </div>

    <div class="mt-2 rounded-2 bg-sys-layer-a px-3 text-sm text-sys-text-body">
      <table class="table-box">
        <thead>
          <tr>
            <th class="text-left">
              RANK
            </th>
            <th class="text-center">
              CASINO
            </th>
            <th class="text-right">
              SPORT
            </th>
          </tr>
        </thead>
        <tbody>
          <tr
            v-for="rank in levelInfo" :key="rank.level"
            :class="{ 'my-level': rank.level === $store.user.userInfo?.vip_level?.level }"
          >
            <td>Rank {{ rank.level }}:  </td>
            <td class="text-center text-sys-text-ter">
              {{ bignumber(rank.cashback_rate).multipliedBy(100) }}%
            </td>
            <td class="text-right text-sys-text-ter">
              {{ bignumber(rank?.sport_cashback_rate).multipliedBy(100) }}%
            </td>
          </tr>
        </tbody>
      </table>
    </div>

    <AButton
      class="ant-cover__Button-3d-primary mt-5"
      type="primary" block
      @click=" emits('close');"
    >
      {{ $t('pFexkGv2pL4Nl4GmT9ZZm') }}
    </AButton>
  </div>
</template>

<style lang="scss" scoped>
.my-level {
  --_radius: var(--radius, 8px);
  --uno: 'text-sys-text-ter! bg-red-6 ';
  > td {
    &:first-child {
      border-top-left-radius: var(--_radius);
      border-bottom-left-radius: var(--_radius);
    }
    &:last-child {
      border-top-right-radius: var(--_radius);
      border-bottom-right-radius: var(--_radius);
    }
  }
}

.table-box {
  width: 100%;

  th,
  td {
    border: none;
    padding: 10px 6px;
  }
}
</style>
